package com.tuozixuan.camel.cron;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy;

public class CronScheduledRoutePolicyDemoRoute extends RouteBuilder {

	@Override
	public void configure() throws Exception {
		
		CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy();
		startPolicy.setRouteStartTime("*/3 * * * * ?");

//		from("direct:start")
//	    .routeId("testRoute").routePolicy(startPolicy).autoStartup(true)
//	    .setBody(simple("Hello ${body}"))
//		.to("log:inboxFileContent?level=DEBUG");
		
//		from("timer:firedOnceTimer?repeatCount=1").routeId("testRoute").routePolicy(startPolicy).autoStartup(false)
//	    .setBody().constant("CronScheduledRoutePolicy demo body")
//	    .to("stream:out");
		
		
		from("timer:firedOnceTimer?repeatCount=1").setBody().constant("CronScheduledRoutePolicy demo body").to("direct:start");
		
		from("direct:start")
	    .routeId("testRoute").routePolicy(startPolicy).noAutoStartup()
	    .to("stream:out");
//	    .to("mock:success");
	}

}
